import { app, ipcMain, globalShortcut, BrowserWindow } from "electron";
import {
  windows,
  hideWindowById,
  showWindowById,
  closeWindowById,
  getWindowById,
  maximizeWindowById,
  minimizeWindowById,
  restoreWindowById,
} from "../jc-electron-tools/windows";

/**窗口管理器通讯*/
export function windowManagerIPC() {
  // 负责 ipc 通信控制窗口
  ipcMain.on("ipc-window-manager-by-id", (event, arg) => {
    const id = arg.id;
    const action = arg.action;
    switch (action) {
      case "hide":
        hideWindowById(id);
        break;
      case "show":
        showWindowById(id);
        break;
      case "maximize":
        maximizeWindowById(id);
        break;
      case "minimize":
        minimizeWindowById(id);
        break;
      case "restore":
        restoreWindowById(id);
        break;
      case "close":
        closeWindowById(id);
        break;
    }
  });
}